package com.LeeCode;

/**
 * 总持续时间可被 60 整除的歌曲
 */

public class Code1010 {
    public static void main(String[] args) {
        int[] time = {30, 20, 150, 100, 40};
        System.out.println(new Code1010().numPairsDivisibleBy60(time));
    }

    public int numPairsDivisibleBy60(int[] time) {
        int[] cnt = new int[60];
        int ans = 0;
        for (int num : time) {
            int index = num % 60;
            if (index == 0)
                ans += cnt[index];
            else
                ans += cnt[60 - index];
            cnt[index]++;
        }
        return ans;
    }
}
